package com.zhang.designmode.wangzheng_design_mode.zhuangtaiji;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: zxz
 * @DateTime: 2022/3/3 18:12
 * @Description: TODO
 */
public class OperatorChecker {
    private static final Map<Status,Step> FLOW = new HashMap<>();

    public static boolean isAllow(Status currentStatus,OperatorStatus operatorStatus){
        Step step = FLOW.get(currentStatus);
        boolean allow = step.isAllow(operatorStatus);
        System.out.println(allow);
        return allow;
    }


    static {
        init();
    }

    private static void init() {
        Step step = new Step(Status.NEW, OperatorStatus.PAY);
        add(step);
        Step step1 = new Step(Status.CANCEL);
        add(step1);
        Step step2 = new Step(Status.PAY, OperatorStatus.PAY, OperatorStatus.CANCEL);
        add(step2);
    }

    private static void add(Step step) {
        FLOW.put(step.getStatus(),step);
    }

}
